<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Test extends SB_Controller {

	function __construct()
	{
		parent::__construct();
	}
	
	function reImage()
	{
		die('=)');
		if(!is_dir(rootDir().'/uploads/articles/'))
			mkdir(rootDir().'/uploads/articles/');

		$this->load->model('admin');
		
		$res = $this->db->get('article')->result();
		foreach ($res as $val)
		{
			$folder = 'uploads/articles/'.$val->id;
			$img = substr(base_url(), 0, -1).$val->pOriginalImg;
			
			if(!is_dir($folder))
				mkdir($folder);
			
			if(!is_dir($folder.'/thumb200'))
				mkdir($folder.'/thumb200');

			if(!is_dir($folder.'/thumb30'))
				mkdir($folder.'/thumb30');
			
			$file = $this->admin->cropImage($folder, $img, array());
			
			echo var_export($file, true).br();
			
			$this->db->where('id', $val->id)->update('article', array(
				'pImg' => $file.'.jpg'
			));
			
			//echo $folder.br();
			//echo $img.br();
			echo '<hr>';
		}
	}

	function sendEmail()
	{
		$this->load->library('email');

		//$this->load->model('email_model', 'mail');
		//$this->mail->sendQueue();
		// $this->mail->sendEmail('isergium@ymail.com', 'title', microtime());
	}
}

?>